package com.fhx.core.keyboard

import android.content.Context
import android.graphics.Color
import android.view.View
import android.widget.RelativeLayout
import android.widget.TextView
import com.fhx.core.R
import com.fhx.core.base.BaseAdapter
import com.fhx.core.base.BaseHolder


class KeyBoardAdapter (mContext: Context, mData: MutableList<Map<String, String>>?):
    BaseAdapter<Map<String, String>>(mContext, mData) {
    override fun initLayout(viewType: Int): Int {
        return R.layout.grid_item_virtual_keyboard
    }

    override fun convert(holder: BaseHolder, item: Map<String, String>, position: Int) {
        holder.addOnChildClickListener(R.id.rl_item)
      val btnKey=  holder.getView<TextView>(R.id.btn_keys)
      val imgDelete=  holder.getView<RelativeLayout>(R.id.imgDelete)
        when(position){
            9->{
                imgDelete.visibility = View.INVISIBLE
                btnKey.visibility = View.VISIBLE
                btnKey.text = data!![position]["name"].toString()
                btnKey.setBackgroundColor(Color.parseColor("#e0e0e0"))
            }
            11->{
                btnKey.setBackgroundResource(R.drawable.keyboard_delete_img)
                imgDelete.visibility = View.VISIBLE
                btnKey.visibility = View.INVISIBLE
            }
            else->{
                imgDelete.visibility = View.INVISIBLE
                btnKey.visibility = View.VISIBLE
                btnKey.text= data!![position]["name"].toString()
            }
        }
    }
}